﻿using IterationLife.Datas;
using IterationLife.Educations.Models;
using IterationLife.Educations.Queries;
using IterationLife.Educations.Repositories;
using IterationLife.PlatformBackEnd.AppServices.Contracts.Educations;
using IterationLife.PlatformBackEnd.AppServices.Dtos.Educations;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.PlatformBackEnd.AppServices.Impl.Educations {
    /// <summary>
    /// 科目分类服务
    /// </summary>
    public class SubjectCategoryService : ApplicationServiceBase<SubjectCategory, SubjectCategoryDto, SubjectCategoryQuery>, ISubjectCategoryService {
        /// <summary>
        /// 初始化科目分类服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="subjectCategoryRepository">科目分类仓储</param>
        public SubjectCategoryService( IApplicationUnitOfWork unitOfWork, ISubjectCategoryRepository subjectCategoryRepository )
            : base( unitOfWork, subjectCategoryRepository ) {
            SubjectCategoryRepository = subjectCategoryRepository;
        }
        
        /// <summary>
        /// 科目分类仓储
        /// </summary>
        protected ISubjectCategoryRepository SubjectCategoryRepository { get; set; }
        
        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override SubjectCategoryDto ToDto( SubjectCategory entity ) {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override SubjectCategory ToEntity( SubjectCategoryDto dto ) {
            return dto.ToEntity();
        }
        
        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">科目分类查询实体</param>
        protected override IQueryBase<SubjectCategory> CreateQuery( SubjectCategoryQuery param ) {
            return new Query<SubjectCategory>( param );
        }
    }
}